package edu.bit.water.controller;

import edu.bit.water.entity.ManagementIndicator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.*;

import edu.bit.water.entity.MetaAI;
import edu.bit.water.service.MetaAIService;


/**
 * 这里对应数据库中Meta_assessment_indicator表的controller
 * 对应企业管理指标
 * @Author： Page
 */
@Controller
@RequestMapping("/meta_assessment_indicator")
public class MetaAIController {

    @Autowired
    private MetaAIService metaAIService = new MetaAIService();

    @ResponseBody
    @RequestMapping(value = "/select", method=RequestMethod.GET)
    public Map<String, Object>selectMetaAI(String stNumber) {
        Map<String, Object> result = new HashMap<>();
        List<MetaAI> list = metaAIService.selectMetaAI(stNumber);
        result.put("rows", list);
        return result;
    }

    @ResponseBody
    @RequestMapping(value = "/select_note", method=RequestMethod.GET)
    public Map<String, Object>selectMetaAINote(String stNumber) {
        Map<String, Object> result = new HashMap<>();
        List<MetaAI> list = metaAIService.selectMetaAINote(stNumber);
        result.put("rows", list);
        return result;
    }
    @ResponseBody
    @RequestMapping("/insert")
    public Map<String, Object> insertMetaAI(MetaAI metaAI) {
        return metaAIService.insertMetaAI(metaAI);
    }

    @ResponseBody
    @RequestMapping("/insert_note")
    public Map<String, Object> insertMetaAINote(MetaAI metaAI) {
        return metaAIService.insertMetaAINote(metaAI);
    }
    /**
     * 删除metaStandard
     * author Page
     */
    @ResponseBody
    @RequestMapping("/delete")
    public Map<String, Object> deleteMetaAI(@RequestBody List<String>metaAIs) {
        return metaAIService.deleteMetaAI(metaAIs);
    }

    @ResponseBody
    @RequestMapping("/delete_note")
    public Map<String, Object> deleteMetaAINote(@RequestBody List<String>metaAIs) {
        return metaAIService.deleteMetaAINote(metaAIs);
    }

    /**
     * 级联删除删除management_indicator
     * author Page
     */
    @ResponseBody
    @RequestMapping("/management_delete")
    public Map<String, Object> managementDelete(@RequestBody List<String> tempData) {
        return metaAIService.managementDelete(tempData);
    }

    @ResponseBody
    @RequestMapping("/update")
    public Map<String, Object> updateMetaStandard(MetaAI metaAI) {
        Map<String, Object> result = metaAIService.updateMetaAI(metaAI);
        return result;
    }
    @ResponseBody
    @RequestMapping("/update_note")
    public Map<String, Object> updateMetaStandardNote(MetaAI metaAI) {
        Map<String, Object> result = metaAIService.updateMetaAINote(metaAI);
        return result;
    }
    @ResponseBody
    @RequestMapping("/management_update")
    public Map<String, Object> managementUpdate(ManagementIndicator managementIndicator) {
        Map<String, Object> result = metaAIService.managementUpdate(managementIndicator);
        return result;
    }
}
